package com.wealth.scsj.b_app.view.activity;

import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.adapter.FragmentAdapter;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;
import com.wealth.scsj.b_app.view.fragment.callmodel.LeftCommFragment;
import com.wealth.scsj.b_app.view.fragment.callmodel.RightCommFragment;

import java.util.ArrayList;

public class CommActivity extends BaseActivity implements View.OnClickListener{

    private NavigationTabStrip tabStrip;
    private ViewPager mViewPager;
    private FragmentAdapter mainFragmentAdapter;
    private String[] titles = {"用户评价", "评价统计"};
    private ImageView ivBack;

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_comm);
        intiNavigationBar();
    }

    @Override
    protected void initView() {
        ivBack= findViewById(R.id.back_img);
        ivBack.setOnClickListener(CommActivity.this);

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    private void intiNavigationBar() {

        //顶部指示器
        tabStrip = findViewById(R.id.mediator_tab);
        mViewPager = findViewById(R.id.viewpager);
        mViewPager.setOffscreenPageLimit(2);
        ArrayList<BaseFragment> list = new ArrayList<>();


        LeftCommFragment leftCommFragment = new LeftCommFragment();
        RightCommFragment rightCommFragment = new RightCommFragment();

        list.add(leftCommFragment);
        list.add(rightCommFragment);

        mainFragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), list);
        mViewPager.setAdapter(mainFragmentAdapter);
        tabStrip.setViewPager(mViewPager, 0);
        tabStrip.setTitles(titles);
        tabStrip.setStripType(NavigationTabStrip.StripType.LINE);
        tabStrip.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM);
        tabStrip.setTabIndex(0, true);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.back_img:
                finish();
                break;
        }
    }
}
